package com.ylx.web.p;

import com.ylx.pojo.Goods;
import com.ylx.service.GoodsService;
import com.ylx.service.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/productInfoServlet")
public class ProductInfoServlet extends HttpServlet {
      private GoodsService goodsService=new GoodsServiceImpl();
    protected void doPost (HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String id = request.getParameter("id");
        Goods goods = goodsService.getProductsById1(id);
        System.out.println(goods);
        request.setAttribute("goods",goods);
        HttpSession session = request.getSession();
        session.setAttribute("goods",goods);
        request.getRequestDispatcher("front/product_info.jsp").forward(request,response);




    }

    protected void doGet (HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        this.doPost(request, response);

    }
}
